package com.fyz.aaronfjava.common.filter;

import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author：AaronF
 * @Date：2024/1/30 15:45
 * @description 自定义过滤器 要在spring环境中使用需要注册到容器中
 */
public class MyFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
//        System.out.println("pre one");
//        String flag = httpServletRequest.getParameter("flag");
//        if (!"one".equals(flag)){
                // 记得要放行
//            filterChain.doFilter(httpServletRequest,httpServletResponse);
//        }
//        System.out.println("post one");
        filterChain.doFilter(httpServletRequest,httpServletResponse);
    }
}
